from data_record.log_utils import logger


def click_exception(by, element1, max_attempts=5):
    def _inner(driver):
        # 多次点击按钮
        actul_attempts = 0
        while actul_attempts < max_attempts:
            actul_attempts += 1
            try:
                driver.find_element(by, element1).click()
                return True
            except Exception:
                logger.debug("点击的时候出现了一次异常")
        raise Exception("超出了最大点击次数")

    return _inner
